<?php
/**
* 店铺服务
*/
class MtStoreSvc extends MtCommon
{
    
    /** 创建或更新门店信息
     * @param $app_poi_code APP方门店ID
     * @param $name 门店名字
     * @param $address 门店地址
     * @param $longitude 门店经度 高德坐标系
     * @param $latitude 门店纬度 高德坐标系
     * @param $phone 客服电话号码
     * @param $shipping_fee 每个订单的配送费
     * @param $shipping_time 门店营业时间
     * @param $open_level 门店的营业状态 ： 1可配送 3休息中
     * @param $is_online 门店上下线状态 ：1表上线,0表下线
     * @param $third_tag_name APP方品类名称
     */
    public function saveShop($app_poi_code, $name, $address, $longitude, $latitude, $phone, $shipping_fee, $shipping_time, $open_level, $is_online, $third_tag_name)
    {
        $data = array();
        $data['app_poi_code'] = $app_poi_code;
        $data['name'] = $name;
        $data['address'] = $address;
        $data['longitude'] = $longitude;
        $data['latitude'] = $latitude;
        $data['phone'] = $phone;
        $data['shipping_fee'] = $shipping_fee;
        $data['shipping_time'] = $shipping_time;
        $data['open_level'] = $open_level;
        $data['is_online'] = $is_online;
        $data['third_tag_name'] = $third_tag_name;

        return $data;
    }
    /** 
     * 发送创建或更新门店信息
     */
    public function sendSaveShop($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("save_shop : " . json_encode($postData, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        $res = $this->sendData('poi/save', $postData, 'POST');

        $this->DLOG("save_shop_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        return $res;
    }

    /** 
         获取门店ID
     */
    public function getIds()
    {
        $data = array();    

        return $data;
    }
    /** 
     * 发送获取门店ID
     */
    public function sendGetIds($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("get_ids : " . json_encode($postData, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        $res = $this->sendData('poi/getids', $postData, 'GET');

        $this->DLOG("get_ids_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        return $res;
    }

    /** 
         批量获取门店信息
         app_poi_codes APP方门店id(半角逗号分隔)
     */
    public function mget($app_poi_codes = '')
    {
        $data = array();
        $data['app_poi_codes']  = $app_poi_codes;   

        return $data;
    }
    /** 
     * 发送批量获取门店信息
     */
    public function sendMget($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("mget : " . json_encode($postData, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        $res = $this->sendData('poi/mget', $postData, 'GET');

        $this->DLOG("mget_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        return $res['data'];
    }

    /** 
         门店设置为营业状态
         app_poi_code APP方门店id
     */
    public function open($app_poi_code = '')
    {
        $data = array();
        $data['app_poi_code']  = $app_poi_code;   

        return $data;
    }
    /** 
     * 发送门店设置为营业状态
     */
    public function sendOpen($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("open : " . json_encode($postData, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        $res = $this->sendData('poi/open', $postData, 'POST');

        $this->DLOG("open_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        return $res;
    }

    /** 
         门店设置为休息状态
         app_poi_code APP方门店id
     */
    public function close($app_poi_code = '')
    {
        $data = array();
        $data['app_poi_code']  = $app_poi_code;   

        return $data;
    }
    /** 
     * 发送门店设置为休息状态
     */
    public function sendClose($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("close : " . json_encode($postData, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        $res = $this->sendData('poi/close', $postData, 'POST');

        $this->DLOG("close_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        return $res;
    }

    /** 
         门店设置为下线状态
         app_poi_code APP方门店id
         reason   下线原因
     */
    public function offline($app_poi_code = '', $reason = '')
    {
        $data = array();
        $data['app_poi_code']  = $app_poi_code;   
        $data['reason']  = $reason;   

        return $data;
    }
    /** 
     * 发送门店设置为下线状态
     */
    public function sendOffline($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("offline : " . json_encode($postData, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        $res = $this->sendData('poi/offline', $postData, 'POST');

        $this->DLOG("offline_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        return $res;
    }

    /** 
         门店设置为上线状态
         app_poi_code APP方门店id
     */
    public function online($app_poi_code = '')
    {
        $data = array();
        $data['app_poi_code']  = $app_poi_code;   

        return $data;
    }
    /** 
     * 发送门店设置为上线状态
     */
    public function sendOnline($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("online : " . json_encode($postData, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        $res = $this->sendData('poi/online', $postData, 'POST');

        $this->DLOG("online_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        return $res;
    }

    /** 
         更改门店广告信息
         app_poi_code APP方门店id
         promotion_info 门店广告栏
     */
    public function updatepromoteinfo($app_poi_code = '', $promotion_info = '')
    {
        $data = array();
        $data['app_poi_code']  = $app_poi_code;   
        $data['promotion_info']  = $promotion_info;   

        return $data;
    }
    /** 
     * 发送更改门店广告信息
     */
    public function sendUpdatepromoteinfo($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("updatepromoteinfo : " . json_encode($postData, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        $res = $this->sendData('poi/updatepromoteinfo', $postData, 'POST');

        $this->DLOG("updatepromoteinfo_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        return $res;
    }

    /** 
         更新门店营业时间
         app_poi_code APP方门店id
         shipping_time 门店营业时间
     */
    public function updateShippingtime($app_poi_code = '', $shipping_time = '')
    {
        $data = array();
        $data['app_poi_code']  = $app_poi_code;   
        $data['shipping_time']  = $shipping_time;   

        return $data;
    }
    /** 
     * 发送更新门店营业时间
     */
    public function sendUpdateShippingtime($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("updateShippingtime : " . json_encode($postData, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        $res = $this->sendData('poi/shippingtime/update', $postData, 'POST');

        $this->DLOG("updateShippingtime_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        return $res;
    }

    /** 
         创建/更新门店配送范围
         app_poi_code APP方门店id
         app_shipping_code APP方提供的配送范围id
         type 配置范围类型
         area 配送范围type 为 1 时: [{"x":39941199,"y":116385384},{ "x":39926983,"y":116361694},{"x ":39921586,"y":116398430}]
         min_price 该配送区域的起送价
     */
    public function saveShipping($app_poi_code = '', $app_shipping_code = '', $type = '', $area = '', $min_price = '')
    {
        $data = array();
        $data['app_poi_code']  = $app_poi_code;   
        $data['app_shipping_code']  = $app_shipping_code;   
        $data['type']  = $type;   
        $data['area']  = $area;   
        $data['min_price']  = $min_price;   

        return $data;
    }
    /** 
     * 发送创建/更新门店配送范围
     */
    public function sendSaveShipping($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("saveShipping : " . json_encode($postData, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        $res = $this->sendData('shipping/save', $postData, 'POST');

        $this->DLOG("saveShipping_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        return $res;
    }

    /** 
         获取门店配送范围
         app_poi_code APP方门店id
     */
    public function shippingList($app_poi_code = '')
    {
        $data = array();
        $data['app_poi_code']  = $app_poi_code;   

        return $data;
    }
    /** 
     * 发送获取门店配送范围
     */
    public function sendShippingList($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("shippingList : " . json_encode($postData, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        $res = $this->sendData('shipping/list', $postData, 'GET');

        $this->DLOG("shippingList_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        return $res;
    }

    /** 
         批量创建/更新配送范围
         app_poi_code APP方门店id
         shipping_data 配送范围集合的json数据
     */
    public function batchsaveShipping($app_poi_code = '', $shipping_data = '')
    {
        $data = array();
        $data['app_poi_code']  = $app_poi_code;   
        $data['shipping_data']  = $shipping_data;   

        return $data;
    }
    /** 
     * 发送批量创建/更新配送范围
     */
    public function sendBatchsaveShipping($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("batchsaveShipping : " . json_encode($postData, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        $res = $this->sendData('shipping/batchsave', $postData, 'POST');

        $this->DLOG("batchsaveShipping_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        return $res;
    }

    /** 
         获取门店品类详细信息列表
     */
    public function tagList()
    {
        $data = array();

        return $data;
    }
    /** 
     * 发送获取门店配送范围
     */
    public function sendTagList($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("tagList : " . json_encode($postData, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        $res = $this->sendData('poiTag/list', $postData, 'POST');

        $this->DLOG("tagList_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_meituan");

        return $res;
    }
}